<?php

/**
 * 
 * 首页格子模型
 */
class GeziModel extends Model {

    private $article, $link;

    public function _initialize() {
        $this->article = M('PayPage');
        $this->link = D('PayLink');
    }

    public function show($limit = 42, $order = 'order_status DESC, create_time DESC') {
        $map = array(
            'end_time' => array('EGT', time()),
            'status' => 1,
            'status_check'=> 'true', 
        );
        //取得满足条件的记录数
        $count = $this->where($map)->count($this->getPk());
        if ($count > (intval($_REQUEST['page']) - 1) *$limit) {
            import("ORG.Util.Page");
            //创建分页对象
            $p = new Page($count, $limit);
            //分页查询数据

            $voList = $this->where($map)->order($order)->limit($p->firstRow . ',' . $p->listRows)->select();
            //分页显示
            $page   = $p->show();
            //模板赋值显示
            $data   = array(
                'list'      => $voList,
                'page'      => $page,
                'nowPage'   => $_REQUEST['page'],
                'totalPage' => round($count / $limit),
            );
        }
        return $data;
    }

}

?>
